<?php 
class Verify_model extends CI_Model
{
	public function __construct()
	{
		$this->load->database();
	}

	public function write($data)
	{
		$exist = $this->db-> get_where('verify',array('record_id'=>$data['record_id']));
		$exist = $exist->result_array();
		if(!empty($exist))
		{
			$update = array('verify_result'=>$data['verify_result']);
			$this->db->update('verify',$update,array('record_id'=>$data['record_id']));
		}
		else
			return $this->db->insert('verify',$data);
		
	}

	public function find($id)
	{
		$data = $this->db->get_where('verify',array('id'=>$id));
		return $data->result_array();

	}

	public function sum($relation)
	{		
		$a =$this->db->select_sum('score')->get_where('verify',$relation);
		return $a->row_array();
	}
}